package com.fire.model.enums;

/**
 * ClassName: Machine
 * Package: com.fire.model.enums
 * Description:
 *
 * @Author: @weixueshi
 * @Create: 2024/3/27 - 15:19
 * @Version: v1.0
 */

import com.alibaba.fastjson.annotation.JSONType;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.databind.deser.std.EnumDeserializer;
import com.fasterxml.jackson.databind.ser.std.EnumSerializer;
import lombok.Getter;

/**
 * 监测异常数据处理情况：0：未处理；1：已处理
 */
@JSONType(serializer = EnumSerializer.class, deserializer = EnumDeserializer.class, serializeEnumAsJavaBean = true)
@Getter
public enum DisposeEnum {
    UNTREATED(0,"未处理"),
    PROCESSED(1,"已处理" );

    @EnumValue
    private Integer code ;
    private String description ;

    DisposeEnum(Integer code, String description ){
        this.code=code;
        this.description=description;
    }

    /**
     * 遍历
     * @param description
     * @return
     */
    public static DisposeEnum getDisposeDescription(String description) {
        for (DisposeEnum disposeEnum : DisposeEnum.values()) {
            if (disposeEnum.description.equalsIgnoreCase(description)) {
                return disposeEnum;
            }
        }
        return null;
    }

    /**
     * 遍历
     * @param code
     * @return
     */
    public static DisposeEnum getDisposeCode(Integer code) {
        for (DisposeEnum disposeEnum : DisposeEnum.values()) {
            if (disposeEnum.getCode().intValue() == code) {
                return disposeEnum;
            }
        }
        return null;
    }
}
